package pww.action;

import a.annotation.Component;
import a.annotation.Inject;
import anntation.Mapping;
import pww.dto.ValueDto;
import pww.entity.Student;
import pww.service.StudentService;
import view.JsonView;
import view.ViewResult;
/**
 * 学生控制器
 */
@Component
public class StudentContrller {
    @Inject("studentServiceImpl")
    private StudentService studentService;
    //添加学生信息  判断是否添加成功7
    @Mapping("register")
    public ViewResult insert(Student student){
        ValueDto dto=new ValueDto();
        int i = studentService.insertStudent(student);
        if (i==1){
            dto.setData(1);
        }else if (i==0){
            dto.setCode(500);
            dto.setMessage("添加失败,昵称重复");
        }
        return new JsonView(dto);
    }

}
